using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class BanklistMap : EntityTypeConfiguration<Banklist>
    {
        public BanklistMap()
        {
            // Primary Key
            this.HasKey(t => t.BANKNO);

            // Properties
            this.Property(t => t.BANKNO)
                .IsRequired()
                .HasMaxLength(2);

            this.Property(t => t.CSHACCT)
                .IsRequired()
                .HasMaxLength(40);

            this.Property(t => t.BANKNAME)
                .IsRequired()
                .HasMaxLength(30);

            this.Property(t => t.BANKBRANCH)
                .HasMaxLength(30);

            this.Property(t => t.BANKADDR)
                .HasMaxLength(30);

            this.Property(t => t.BANKCODE)
                .HasMaxLength(25);

            this.Property(t => t.BANKENCD)
                .HasMaxLength(56);

            this.Property(t => t.CHKNOPOS)
                .HasMaxLength(6);

            this.Property(t => t.DATEPOS)
                .HasMaxLength(6);

            this.Property(t => t.NUMAMTPOS)
                .HasMaxLength(6);

            this.Property(t => t.STRAMTPOS)
                .HasMaxLength(6);

            this.Property(t => t.VENDPOS)
                .HasMaxLength(6);

            this.Property(t => t.STUB1POS)
                .HasMaxLength(2);

            this.Property(t => t.STUB2POS)
                .HasMaxLength(2);

            this.Property(t => t.File_Primary_Key)
                .HasMaxLength(10);

            // Table & Column Mappings
            this.ToTable("Banklist");
            this.Property(t => t.BANKNO).HasColumnName("BANKNO");
            this.Property(t => t.CSHACCT).HasColumnName("CSHACCT");
            this.Property(t => t.LASERCKS).HasColumnName("LASERCKS");
            this.Property(t => t.BANKNAME).HasColumnName("BANKNAME");
            this.Property(t => t.BANKBRANCH).HasColumnName("BANKBRANCH");
            this.Property(t => t.BANKADDR).HasColumnName("BANKADDR");
            this.Property(t => t.BANKCODE).HasColumnName("BANKCODE");
            this.Property(t => t.BANKENCD).HasColumnName("BANKENCD");
            this.Property(t => t.CHECKNO).HasColumnName("CHECKNO");
            this.Property(t => t.INUSE).HasColumnName("INUSE");
            this.Property(t => t.CHKNOPOS).HasColumnName("CHKNOPOS");
            this.Property(t => t.DATEPOS).HasColumnName("DATEPOS");
            this.Property(t => t.NUMAMTPOS).HasColumnName("NUMAMTPOS");
            this.Property(t => t.STRAMTPOS).HasColumnName("STRAMTPOS");
            this.Property(t => t.VENDPOS).HasColumnName("VENDPOS");
            this.Property(t => t.STUB1POS).HasColumnName("STUB1POS");
            this.Property(t => t.STUB2POS).HasColumnName("STUB2POS");
            this.Property(t => t.BANKCURR).HasColumnName("BANKCURR");
            this.Property(t => t.File_Primary_Key).HasColumnName("File Primary Key");

            // Relationships
            this.HasRequired(t => t.Acct)
                .WithMany(t => t.Banklists)
                .HasForeignKey(d => d.CSHACCT);
            this.HasOptional(t => t.currency)
                .WithMany(t => t.Banklists)
                .HasForeignKey(d => d.BANKCURR);

        }
    }
}
